// YL_DEMO_VOIPDlg.cpp : implementation file
//

#include "stdafx.h"
#include "YL_DEMO_VOIP.h"
#include "YL_DEMO_VOIPDlg.h"
#include "P1KDlg.h"
#include "B2KDlg.h"
#include "B3GDlg.h"
#include "P4KDlg.h"
#include "P8DDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CYL_DEMO_VOIPDlg dialog

CYL_DEMO_VOIPDlg::CYL_DEMO_VOIPDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CYL_DEMO_VOIPDlg::IDD, pParent)
	, m_strEeprom(_T(""))
{
	//{{AFX_DATA_INIT(CYL_DEMO_VOIPDlg)
	//}}AFX_DATA_INIT
	m_pDlg = NULL;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_bOpened = FALSE;
}

CYL_DEMO_VOIPDlg::~CYL_DEMO_VOIPDlg()
{
	if ( NULL != m_pDlg )
		delete m_pDlg;
}

void CYL_DEMO_VOIPDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CYL_DEMO_VOIPDlg)
	DDX_Control(pDX, IDC_EDIT_MESSAGE, m_Edit);
	DDX_Control(pDX, IDC_SLIDER2, m_MicCtrl);
	DDX_Control(pDX, IDC_SLIDER1, m_SpkCtrl);
	//}}AFX_DATA_MAP
	DDX_Text(pDX, IDC_EDIT_EEPROM, m_strEeprom);
}

BEGIN_MESSAGE_MAP(CYL_DEMO_VOIPDlg, CDialog)
	//{{AFX_MSG_MAP(CYL_DEMO_VOIPDlg)
	ON_MESSAGE(WM_TIMER,							OnTimer)
	ON_BN_CLICKED(IDC_BUTTON_OPEN, OnOpenDevice)
	ON_BN_CLICKED(IDC_BUTTON_CLOSE, OnDeviceClose)
	ON_BN_CLICKED(IDC_CONNECTING, OnConnecting)
	ON_BN_CLICKED(IDC_RINGBACK, OnRingback)
	ON_BN_CLICKED(IDC_CALLFAIL, OnCallfail)
	ON_BN_CLICKED(IDC_CALLIN, OnCallin)
	ON_BN_CLICKED(IDC_INTALK, OnIntalk)
	ON_BN_CLICKED(IDC_ONHOLD, OnOnhold)
	ON_BN_CLICKED(IDC_OUTTALK, OnOuttalk)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSliderSPK)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER2, OnReleasedcaptureSlider2)
	ON_BN_CLICKED(IDC_READY, OnReady)
	ON_BN_CLICKED(IDC_DIALING, OnDialing)
	ON_BN_CLICKED(IDC_ADVANCED, OnAdvanced)
	ON_WM_CLOSE()
	ON_BN_CLICKED(IDC_CLEAR, OnClear)
	ON_MESSAGE(WM_YLCALLBACK, OnYlCallBack)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_PSTNDIALING, &CYL_DEMO_VOIPDlg::OnBnClickedPstndialing)
	ON_BN_CLICKED(IDC_READEEPROM, &CYL_DEMO_VOIPDlg::OnBnClickedReadeeprom)
	ON_BN_CLICKED(IDC_WRITEEEPROM, &CYL_DEMO_VOIPDlg::OnBnClickedWriteeeprom)
END_MESSAGE_MAP()


static void YLCallBack(LPVOID wParam, LPVOID lParam, DWORD pApp)
{
	CYL_DEMO_VOIPDlg *pThis = (CYL_DEMO_VOIPDlg *)pApp;

	::PostMessage(pThis->m_hWnd, WM_YLCALLBACK, (WPARAM)wParam, (LPARAM)lParam);
}
/////////////////////////////////////////////////////////////////////////////
// CYL_DEMO_VOIPDlg message handlers

BOOL CYL_DEMO_VOIPDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	m_SpkCtrl.SetRange(0,100);
	m_MicCtrl.SetRange(0,100);

	m_SpkCtrl.SetPos( 0 );
	m_MicCtrl.SetPos( 0 );

/*
	typedef BOOL (*MYPROC)(DWORD, LPVOID, LPVOID, LPVOID, LPVOID, LPDWORD); 
	
	HMODULE m_hDllModule = ::LoadLibrary( _T("YLUSBTEL.dll") );
	MYPROC pFunc = (MYPROC)::GetProcAddress( m_hDllModule, "YL_DeviceIoControl" );
	if ( !pFunc(YL_IOCTL_OPEN_DEVICE, (LPVOID)YLCallBack, (LPVOID)this,0,0,0))
	{
		::FreeLibrary( m_hDllModule );
	}
*/

	OnOpenDevice();

	return FALSE;
}


void CYL_DEMO_VOIPDlg::OnOpenDevice() 
{
	if ( m_bOpened )
	{
		return;
	}

	if ( YL_DeviceIoControl(YL_IOCTL_OPEN_DEVICE, (LPVOID)YLCallBack, (LPVOID)this) )
	{
		YL_DeviceIoControl(YL_IOCTL_GET_PHONEVERSION, &m_lVersion);
		CString strVersionNO = _T("");
		strVersionNO.Format( _T("0x%x"), m_lVersion );
		GetDlgItem(IDC_VERSION)->SetWindowText( strVersionNO );

		TCHAR szSerialNO[32] = _T("");
		YL_DeviceIoControl(YL_IOCTL_GET_PHONESERIALNO, (LPVOID)szSerialNO, (LPVOID)32);
		GetDlgItem(IDC_SERIAL)->SetWindowText( szSerialNO );
		
		TCHAR strSpkName[32] = _T("");
		YL_DeviceIoControl(YL_IOCTL_GET_SPEAKNAME, (LPVOID)strSpkName, (LPVOID)32);
		GetDlgItem(IDC_OUTPUT)->SetWindowText( strSpkName );

		TCHAR strMicName[32] = _T("");
		YL_DeviceIoControl(YL_IOCTL_GET_MICNAME, (LPVOID)strMicName, (LPVOID)32);
		GetDlgItem(IDC_INPUT)->SetWindowText( strMicName );
		
		LONG lVol = 0;
		YL_DeviceIoControl(YL_IOCTL_GET_SPEAKVOLUME, &lVol);
		m_SpkCtrl.SetPos(lVol);
		YL_DeviceIoControl(YL_IOCTL_GET_MICVOLUME, &lVol);
		m_MicCtrl.SetPos(lVol);
		
		UpdateData( FALSE );
		
		m_bOpened = TRUE;
		GetDlgItem(IDC_ADVANCED)->EnableWindow( TRUE );
		if (IS_DUALPhones(m_lVersion))
		{
			GetDlgItem(IDC_PSTNDIALING)->EnableWindow( TRUE );
		}
		else
		{
			GetDlgItem(IDC_PSTNDIALING)->EnableWindow( FALSE );
		}
		m_uCurrentStatus = PHONE_STATUS_READY;
		SetWindowText( _T("Open USB Phone successfully") );
	}
	else
	{
		m_bOpened = FALSE;
		GetDlgItem(IDC_ADVANCED)->EnableWindow( FALSE );
		GetDlgItem(IDC_PSTNDIALING)->EnableWindow( FALSE );
		SetWindowText( _T("Please insert USB Phone") );
	}
}

void CYL_DEMO_VOIPDlg::OnDeviceClose() 
{
	YL_DeviceIoControl(YL_IOCTL_CLOSE_DEVICE);

	m_bOpened = FALSE;
	GetDlgItem(IDC_ADVANCED)->EnableWindow( FALSE );
	GetDlgItem(IDC_SERIAL)->SetWindowText( _T("") );
	GetDlgItem(IDC_VERSION)->SetWindowText( _T("") );
	GetDlgItem(IDC_OUTPUT)->SetWindowText( _T("") );
	GetDlgItem(IDC_INPUT)->SetWindowText( _T("") );

	m_lVersion = 0;
	m_SpkCtrl.SetPos( 0 );
	m_MicCtrl.SetPos( 0 );

	if ( NULL != m_pDlg )
	{
		m_pDlg->DestroyWindow();
		delete m_pDlg;
		m_pDlg = NULL;
	}
	

	UpdateData( FALSE );
}

void CYL_DEMO_VOIPDlg::OnReleasedcaptureSliderSPK(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if ( !m_bOpened )
	{
		m_SpkCtrl.SetPos( 0 );
		return;
	}

	YL_DeviceIoControl(YL_IOCTL_SET_SPEAKVOLUME,(LPVOID)m_SpkCtrl.GetPos());
	
	CString strTemp = _T("DEVICE_CMD SET_OUTPUT_VOLUME\r\n");
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
	
	*pResult = 0;
}

void CYL_DEMO_VOIPDlg::OnReleasedcaptureSlider2(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if ( !m_bOpened )
	{
		m_MicCtrl.SetPos( 0 );
		return;
	}

	YL_DeviceIoControl(YL_IOCTL_SET_MICVOLUME, (LPVOID)m_MicCtrl.GetPos());
	
	CString strTemp = _T("DEVICE_CMD SET_INPUT_VOLUME\r\n");
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
	
	*pResult = 0;
}

void CYL_DEMO_VOIPDlg::OnReady() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_READY);
	m_uCurrentStatus = PHONE_STATUS_READY;

	CString strTemp = _T("DEVICE_CMD READY\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnDialing() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_DIALING, _T("1234567890123456789") );
	m_uCurrentStatus = PHONE_STATUS_DIALING;
	
	CString strTemp = _T("DEVICE_CMD DIALING\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}


void CYL_DEMO_VOIPDlg::OnConnecting() 
{
	if ( !m_bOpened )
		return;

	YL_DeviceIoControl(YL_IOCTL_GEN_CALLOUT, _T("Connecting") );
	m_uCurrentStatus = PHONE_STATUS_CONNECTING;
	
	CString strTemp = _T("DEVICE_CMD CONNECTING\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnRingback() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_RINGBACK, _T("Ringback"));	
	m_uCurrentStatus = PHONE_STATUS_RINGBACK;
	
	CString strTemp = _T("DEVICE_CMD RINGBACK\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}
void CYL_DEMO_VOIPDlg::OnCallfail() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_CALLFAILED, _T("Callfailed"));	
	m_uCurrentStatus = PHONE_STATUS_CALLFAIL;
	
	CString strTemp = _T("DEVICE_CMD CALLFAILED\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnIntalk() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_TALKING, _T("Intalk"));
	m_uCurrentStatus = PHONE_STATUS_INTALK;
	
	CString strTemp = _T("DEVICE_CMD INTALK\r\n");
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnOnhold() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_HOLD, _T("Hold"));
	m_uCurrentStatus = PHONE_STATUS_ONHOLD;
	
	CString strTemp = _T("DEVICE_CMD HOLD\r\n");
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}


void CYL_DEMO_VOIPDlg::OnOuttalk() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_OUTTALK, _T("Outtalk"));
	m_uCurrentStatus = PHONE_STATUS_OUTTALK;
	
	CString strTemp = _T("DEVICE_CMD OUTTALK\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnCallin() 
{
	if ( !m_bOpened )
		return;
	
	YL_DeviceIoControl(YL_IOCTL_GEN_CALLIN, _T("987654321"));	
	m_uCurrentStatus = PHONE_STATUS_CALLIN;
	
	CString strTemp = _T("DEVICE_CMD CALLIN\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnAdvanced() 
{
	if ( !m_bOpened )
		return;

	if ( NULL != m_pDlg )
	{
		m_pDlg->ShowWindow( SW_SHOW );
		return;
	}

	if ( IS_P1Ks(m_lVersion) )
	{
		m_pDlg = new CP1KDlg(this);
		m_pDlg->Create( IDD_P1K, this );
		m_pDlg->ShowWindow( SW_SHOW );
	}
	else if ( IS_P3Ks(m_lVersion)|| IS_T4K(m_lVersion) )
	{
		m_pDlg = new CP4KDlg(this);
		m_pDlg->Create( IDD_P4K, this );
		m_pDlg->ShowWindow( SW_SHOW );
	}
	else if ( IS_B2K(m_lVersion) )
	{
		m_pDlg = new CB2KDlg(this);
		m_pDlg->Create( IDD_B2K, this );
		m_pDlg->ShowWindow( SW_SHOW );
	}
	else if ( IS_B3K(m_lVersion) )
	{
		m_pDlg = new CB3GDlg(this);
		m_pDlg->Create( IDD_B3G, this );
		m_pDlg->ShowWindow( SW_SHOW );
	}
	else if ( IS_P8Ds(m_lVersion) || IS_W1D(m_lVersion))
	{
		m_pDlg = new CP8DDlg(this);
		m_pDlg->Create( IDD_P8D, this );
		m_pDlg->ShowWindow( SW_SHOW );
	}

}

LRESULT CYL_DEMO_VOIPDlg::OnYlCallBack(WPARAM wParam, LPARAM lParam)
{
	switch(wParam)
	{
	case YL_CALLBACK_MSG_ERROR:
		{
			CString strTemp = _T("DEVICE_EVENT LOSE\r\n");
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
			
			m_bOpened = FALSE;
			m_lVersion = 0;
			GetDlgItem(IDC_ADVANCED)->EnableWindow( FALSE );
			GetDlgItem(IDC_SERIAL)->SetWindowText( _T("") );
			GetDlgItem(IDC_VERSION)->SetWindowText( _T("") );
			GetDlgItem(IDC_OUTPUT)->SetWindowText( _T("") );
			GetDlgItem(IDC_INPUT)->SetWindowText( _T("") );
			
			m_SpkCtrl.SetPos( 0 );
			m_MicCtrl.SetPos( 0 );
		
			if ( NULL != m_pDlg )
			{
				delete m_pDlg;
				m_pDlg = NULL;
			}
		
			UpdateData( FALSE );
		}
		break;
	case YL_CALLBACK_MSG_USBPHONE_VERSION:
		break;
	case YL_CALLBACK_MSG_USBPHONE_SERIALNO:
		break;
	case YL_CALLBACK_GEN_KEYBUF_CHANGED:
		break;
	//case YL_CALLBACK_MSG_KEYDOWN:
	case YL_CALLBACK_GEN_KEYDOWN:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT KEYDOWN [%d]\r\n"), lParam );
/*
			if (lParam == 129)
			{
				YL_DeviceIoControl(YL_IOCTL_SET_B3GCURRENTCHANNEL, (LPVOID)CHANNEL_USB);
			}
*/
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_MSG_KEYUP:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT KEYUP [%d]\r\n"), lParam );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_OFFHOOK:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT PHONE_OFFHOOK\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_HANGUP:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT PHONE_ONHOOK\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_INUSB:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT CHANNEL_USB\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_INPSTN:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT CHANNEL_PSTN\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_PSTNRING_START:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT PHONE_RINGSTART\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_PSTNRING_STOP:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT PHONE_RINGSTOP\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_PSTN_BUSY:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT PSTN_BUSY\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_W1D_DOCK:
		{
			CString strTemp = _T("");
			
			if ( lParam )
				strTemp.Format( _T("DEVICE_EVENT PHONE_DOCK\r\n") );
			else
				strTemp.Format( _T("DEVICE_EVENT PHONE_UNDOCK\r\n") );
			
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_W1D_LOWSIGNAL:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT W1D_LOW_SIGNAL\r\n") );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	case YL_CALLBACK_GEN_PSTN_CALLERID:
		{
			CString strTemp = _T("");
			strTemp.Format( _T("DEVICE_EVENT PSTN_CID:%s\r\n"), (LPCTSTR)lParam );
			m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
			m_Edit.ReplaceSel( strTemp, FALSE );
		}
		break;
	default:
		break;
	}
	return 0;
}

void CYL_DEMO_VOIPDlg::OnClose() 
{
	YL_DeviceIoControl(YL_IOCTL_CLOSE_DEVICE);
	
	CDialog::OnClose();
}


void CYL_DEMO_VOIPDlg::OnClear() 
{
	m_Edit.SetSel( 0, -1, FALSE );
	m_Edit.ReplaceSel( _T(""), FALSE );
}


void CYL_DEMO_VOIPDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	
}

void CYL_DEMO_VOIPDlg::OnBnClickedPstncall()
{
	// TODO: Add your control notification handler code here
	if ( !m_bOpened )
		return;


}

void CYL_DEMO_VOIPDlg::OnBnClickedPstndialing()
{
	if ( !m_bOpened )
		return;

	YL_DeviceIoControl(YL_IOCTL_PSTN_DIALING, _T("910000"));
	m_uCurrentStatus = 	PHONE_STATUS_PSTNDIALING;
	CString strTemp = _T("DEVICE_CMD PSTNDIALING\r\n");	
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnBnClickedReadeeprom()
{
	if ( !m_bOpened )
		return;
	TCHAR strBuffer[MAX_PATH] = _T("");
	YL_DeviceIoControl(YL_IOCTL_EEPROM_HANDLE, 0, (LPTSTR)strBuffer);
	CString strTemp = _T("");	
	strTemp.Format(_T("READ EEPROM {%s}\r\n"), strBuffer);
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
}

void CYL_DEMO_VOIPDlg::OnBnClickedWriteeeprom()
{
	if ( !m_bOpened )
		return;
	UpdateData(TRUE);
	YL_DeviceIoControl(YL_IOCTL_EEPROM_HANDLE, (LPVOID)1, (LPVOID)(LPCTSTR)m_strEeprom);
	CString strTemp = _T("");	
	strTemp.Format(_T("WRITE EEPROM {%s}\r\n"), m_strEeprom);
	m_Edit.SetSel( m_Edit.GetLimitText(), -1, FALSE );
	m_Edit.ReplaceSel( strTemp, FALSE );
	// TODO: Add your control notification handler code here
}
